package com.cw.util;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * @BelongsProject: cmhn
 * @BelongsPackage: com.ck.cmhn.common.util
 * @Author: lp
 * @CreateTime: 2023-02-08  16:10
 * @Description: TODO
 * @Version: 1.0
 */
public  final class EncodeUtils {

        private static final String DEFAULT_URL_ENCODING = "UTF-8";

        public static String urlEncode(String part) {
            try {
                return URLEncoder.encode(part, DEFAULT_URL_ENCODING);
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException( e);
            }
        }

        /**
         * URL 解码, Encode默认为UTF-8.
         */
        public static String urlDecode(String part) {

            try {
                return URLDecoder.decode(part, DEFAULT_URL_ENCODING);
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }



}
